home *** CD-ROM | disk | FTP | other *** search
/ Gigarom 1 / Gigarom Macintosh Archives (Quantum Leap)(CDRM1080320)(1993).iso / FILES / DEV / I-Z / TML_Skel.Pas.cpt / TML SKEL.PAS
Pascal/Delphi Source File  |  1986-04-28  |  25KB  |  465 lines

  1. PROGRAM Skel;
  2. {          By    Steve Maker
  3.                  Academic Computing
  4.                  Kiewit Computation Center
  5.                  Dartmouth College
  6.                  July 14, 1984
  7. Copyright notice:
  8.            SKEL may be copied and used by anyone, so long as that use
  9.            is not for commercial purposes.  Please send significant changes
  10.            back to me so that I may incorporate them into future versions.
  11. Why SKEL?
  12.            Skel is a skeleton demo program.  Its purpose is to illustrate
  13.            in a clear fashion, isolated from any particular application,
  14.            the basic code for handling a simple Macintosh user interface.
  15.            It strives to be correct as far as it goes, without many short-cuts
  16.            that would lead to trouble in larger applications.
  17.            I think of SKEL as a program that does nothing, but does it well.
  18. What does SKEL do?
  19.            It handles:
  20.                Events, carefully handling only those which are its
  21.                        business, and passing the others on to their
  22.                        respective handlers.
  23.                A Window, which is filled with Dark Gray, and can be
  24.                        activated or inactivated, updated, dragged
  25.                        and grown but NOT scrolled or closed.
  26.                Menus, including the Apple Menu.  An "About Skel" menu entry
  27.                        is provided.  A File menu offers Rattle and Frighten,
  28.                        which just invoke dialog boxes, and Quit.  Command
  29.                        key equivalents are supported.
  30.                The Desk Accessories, supported in the Apple menu,
  31.                        and correctly meshed with the other features.
  32.                        NOT supported are Undo, Cut, Copy, Paste and Clear
  33.                        (and keyboard equivalents) for desk accessories.
  34.                A Modal Dialog Box, used to communicate with the user.
  35.                Special icons for the application and its related files.
  36.                The Finder information (in the resource file).
  37.            In accordance with Macintosh guidelines, everything possible is
  38.            kept in the resource file: window description, menus,
  39.            dialog specification, and the "About Skel" and other strings.
  40.            In addition, the resource file handles the Bundle, File References,
  41.            and Icons that determine what Skel's icon looks like, and other
  42.            information for the Finder.
  43. How do I use SKEL?
  44.            Study it.  Modify it to test your knowledge.  Steal working
  45.            pieces of code for your own programs.  Beat on it.  Subject
  46.            it to cruel and unusual experiments.  Pay heed to its warnings.
  47. What do I study first in SKEL?
  48.            Initially you should ignore several sections of SKEL, and the calls
  49.            made to them.  I recommend X-ing them out in your listing.
  50.            The sections to ignore on the first round of study are:
  51.                Report: ignore the implementation
  52.                SetUpMemory: ignore all of it
  53.                DrawWindow: ignore the scroll bar and grow icon handling
  54.                ReSize: ignore all of it
  55.                DoCommand: ignore the Desk Accessory handling in the Apple Menu
  56.                MainEventLoop:
  57.                   MouseDown handling: ignore inSysWindow, inDrag, inGrow
  58.                   keyDown, autoKey handling: ignore this.
  59.            In the resource definition file, SKELR:
  60.                Finder information (offset by asterisks):
  61.                   ignore this whole section, icons and all.
  62. What should I read in Inside Macintosh?
  63.            You should read the following sections of Inside Macintosh,
  64.            in the order given.  At first, just lightly skim the sections
  65.            with parenthesized names.  Read the others in some depth.  Read
  66.            the starred (*) ones in great detail.  Eventually, you will have
  67.            read all sections thoroughly, and many many times, I promise you.
  68.            To start:
  69.              * Inside Macintosh: A Road Map
  70.               (User Interface Guidelines)
  71.                Structure of a Macintosh Application
  72.              * Putting Together a Macintosh Application
  73.            Then, (low-level sections are listed first):
  74.             *  Memory Mgr Intro
  75.               (Memory Mgr)
  76.             *  Resource Mgr (through "Using the Resource Mgr")
  77.             *  QuickDraw
  78.               (Desk Mgr)
  79.             *  Event Mgr (through "Event Mgr routines")
  80.                Window Mgr
  81.                Menu Mgr
  82.               (Dialog Mgr)
  83. How do I get SKEL to run?
  84.            The best way is to use the special EXEC file SKELX, and insert a
  85.            Macintosh diskette into your Lisa.  SKELX will write on it with
  86.            MacCom, and will set all info correctly so that the icon will appear.
  87.            You may also use Apple's EXEC file, or the Dartmouth exec files
  88.            T/EXEC or M/MACCOM.  The first two will not set the icon correctly,
  89.            while M/MACCOM will do that right, and also refrain from recompiling
  90.            or repeating other steps if they are unnecessary.
  91. What are the funny % describes for?
  92.            They are formatting commands for a Pascal formatter used at Dartmouth
  93.            on Lisa Pascal code, for producing a readable listing.
  94. What is the history of SKEL?
  95.       v1.0 July 14, 1984   sm: major revision of earlier version
  96.            Sept 30, 1984   sm: used \14 for apple symbol in res. file,
  97.                                bracketed OpenDeskAcc with Get and SetPort,
  98.            Oct 11, 1984   sm:  changed FREF, BNDL resources from HEXA
  99.                                   to readable,
  100.                                nested some routines in SKEL,
  101.                                added constants for FILE menu items,
  102.       v2.0 Nov 12, 1984   sm:  made resources pre-loaded and/or purgeable,
  103.                                turned off range-checking,
  104.                                documented no Resume proc passed to InitDialogs,
  105.                                added SetUpMemory:
  106.                                   calls MoreMasters, MaxApplZone,
  107.                                   sets the NIL address to -1,
  108.                                   lots of general memory doc.
  109.                                added a warning about passing doubly-
  110.                                   dereferenced handles,
  111.                                removed en/disabling of Rattle and Frighten items,
  112.       v2.1 Dec 4, 1984    sm:  added menu key handling,
  113.                                put Rattle and Frighten strings in res file,
  114.                                rewrote intro documentation
  115.       v2.2 Mar 6, 1985    sm:  converted to % describes,
  116.                                fixed SKELX for both 2.0 and 3.0 workshop,
  117.                                set the event mask
  118.       v2.2.1 Jan 12, 1986 va:  Converted to work with TML Pascal;
  119.                          also required conversion of resource file.
  120.                    Vic Abell
  121. }
  122.       {$B+ }
  123.       {$I MemTypes.Ipas    }
  124.       {$I QuickDraw.Ipas   }
  125.       {$I OSIntf.Ipas      } 
  126.       {$I ToolIntf.Ipas    }
  127.       {$I PackIntf.Ipas    }
  128.       {$I FixMath.Ipas     }
  129.       {$I Graf3D.Ipas      }
  130.       {$I MacPrint.Ipas    }
  131.       {$L Skel/Rsrc }
  132.       {$T APPL SKEL }
  133.    CONST
  134.       firstMenu = 256;
  135.       lastMenu = 257;    { number of menus }
  136.       appleMenu = 256;   { menu ID for desk accessory menu }
  137.       fileMenu = 257;    { menu ID for File menu }
  138.       iRattle = 1;     {items in the File menu}
  139.       iFrighten = 2;
  140.       {--------}
  141.       iQuit = 4;
  142.     VAR
  143.       screenPort: GrafPtr;         {a port for the whole screen}
  144.       myWindow: WindowPtr;         {our one window}
  145.       wRecord: WindowRecord;       {storage for window record}
  146.       dragRect: Rect;              {rect to drag within}
  147.       growRect: Rect;              {bounds for the growth of the windows}
  148.       myMenus: ARRAY [firstMenu..lastMenu] OF MenuHandle;   {our menus}
  149.   {############################   Report   #################################}
  150.   {   We put up a dialog box, show the string, and wait for user to hit OK.}
  151.    PROCEDURE Report(reportstr: str255);
  152.       CONST RptBoxID = 257;   {ID of our report dialog in resource file}
  153.             rptText = 2;      {Item # of dialog's report text}
  154.       VAR
  155.          itemhit: INTEGER;    {which Item was clicked on (only OK avail)}
  156.          ReportPtr: DialogPtr;
  157.       BEGIN {Report}
  158.          {set text to display}
  159.          ParamText(reportStr, '', '', '');
  160.          ReportPtr := getNewDialog(RptBoxID, NIL, pointer(-1));    {get from Resource file;
  161.                                                                     NIL => use heap storage;
  162.                                                                     -1 => make dlg frontmost}
  163.          ModalDialog(NIL, itemHit);     {carry out dialog;
  164.                                          NIL => no FilterProc;
  165.                                          return item Hit when done}
  166.          DisposDialog(ReportPtr);        {release storage and remove dialog from screen}
  167.       END; {Report}
  168.   {############################   SetUp   #################################}
  169.   {   Initialize our program.  It seems best to handle:
  170.    Memory inits first, ToolBox inits second, then the program variables' inits.
  171.    Note that the order of inits is important; see "Using the Dialog Manager"
  172.    in the Dialog Mgr section.}
  173.   PROCEDURE SetUp;
  174.      CONST
  175.         WindowID = 260;       {Resource ID for my window}
  176.      VAR
  177.         screenRect: rect;     {size of screen; could be machine-dependent}
  178.   {############################   SetUpMemory   #################################}
  179.   {   This very important set of initializations can be left out of the first
  180.    versions of a program. We are making sure that memory is laid out as
  181.    we desire, with adequate protection against running out of memory, bad
  182.    handles, etc.}
  183. Procedure SetUpMemory;
  184.    CONST
  185.          maxStackSize = 8192;     {max size of stack; the heap gets the rest}
  186.    TYPE
  187.         loMemPtr = ^longint;      {a pointer to low memory locations}
  188.    VAR
  189.        nilPtr: loMemPtr;          {will have value NIL}
  190.        stackBasePtr: loMemPtr;    {points to current stack base}
  191.    BEGIN {SetUpMemory}
  192.         {If you define a GrowZone function to handle bad memory problems,
  193.          you should define it at the top level (not nested), and set it here.
  194.          We don't.}
  195.      (*  SetGrowZone(@MyGrowZone);
  196.      *)
  197.         {Place a longint -1 (an odd and therefore illegal address) in the
  198.          memory location that would be referenced by an accidentally-NIL
  199.          handle, so the error will be caught at handle-reference time (as
  200.          an Address error, ID=02) instead of later on.}
  201. {        nilPtr := NIL;
  202.         nilPtr^ := -1;}
  203.         {If you needed to use an Application heap limit other than the default
  204.          (which allows 8K for the stack), you'd set it here, possible using this
  205.          technique of explicitly specifying the maximum stack size and allocating
  206.          the rest to the heap.  Should be independent of memory size. }
  207.         stackBasePtr := loMemPtr($908);    {CurStackBase from Tlasm/sysequ.text}
  208.         SetApplLimit( pointer(stackBasePtr^ - maxStackSize) );
  209.         {Expand the application heap zone to its maximum size, without purging
  210.          any purgeable resources.  This saves memory compactions and heap expansions later.}
  211.         MaxApplZone;
  212.         {get plenty of master pointers now; if we let the Memory Manager allocate
  213.          them as needed, they'd form non-relocatable islands in the heap.}
  214.         MoreMasters;  MoreMasters;  MoreMasters;
  215.         {Here you might install bulwarks against running out of memory unexpectedly.
  216.          One such (cheesy) technique is to here allocate a large handle, call it
  217.          "CheeseBuf", which you can de-allocate in your GrowZone function, when
  218.          you must obtain more memory to avoid a crash.  While de-allocated,
  219.          the program could prevent the user from doing anything requiring memory,
  220.          and tell him he must discard windows or some such memory freeing action.
  221.          Each time he does so, the program can try to re-allocate CheeseBuf; if it
  222.          succeeds, the user can go on doing memory-eating operations.}
  223.    END; {SetUpMemory}
  224.   {############################   SetUpMenus   #################################}
  225.   {   We read in all menus from the resource file, and install them,
  226.     and all desk accessories (drivers).}
  227.   PROCEDURE SetUpMenus;
  228.      VAR
  229.         i: INTEGER;
  230.      BEGIN {SetUpMenus}
  231.         for i := firstMenu to lastMenu do    {get all my menus in}
  232.            myMenus[i] := GetMenu(i);
  233.         AddResMenu(myMenus[appleMenu], 'DRVR');    {pull in all desk accessories }
  234.         for i := firstMenu to lastMenu do
  235.            InsertMenu(myMenus[i], 0);          {insert menus; 0 => put at end}
  236.         DrawMenuBar;
  237.      END; {SetUpMenus }
  238.      BEGIN {SetUp}
  239.         {init memory layout and protection}
  240.         SetUpMemory;
  241.         {init QuickDraw, and everybody else}
  242.         InitGraf(@thePort);
  243.     MoreMasters;
  244.     MoreMasters;
  245.     MoreMasters;
  246.     MoreMasters;
  247.     MoreMasters;
  248.         InitFonts;
  249.         InitWindows;
  250.         InitMenus;
  251.         TEInit;
  252.         InitDialogs(NIL); {NIL => no Restart proc; see Dialog Mgr and System Error Handler}
  253.         InitCursor;
  254.         {Init the system event mask, in case the previous program left it in
  255.          a bad state.  If you set it non-standard here, FIX IT BEFORE EXITING,
  256.          because the Finder (1.1g) does NOT set it.}
  257.         SetEventMask(everyEvent - keyUpMask);     {standard setting}
  258.         {Get the port which is the whole screen, to use when deactivating our window.
  259.            This prevents the current grafPort pointer from ever dangling.}
  260.         GetWMgrPort(screenPort);   {get whole screen port that window mgr uses}
  261.         SetPort(screenPort);       {and start off with it}
  262.         {get window: use wRecord storage.  Port is set to that of the new window.
  263.             GetNewWindow posts an update event for the new window,
  264.             so it will be redrawn right away.}
  265.         myWindow := GetNewWindow(windowID, @wRecord, POINTER(-1));    {-1 => frontmost window}
  266.         {set up dragRect; we can drag the window within it}
  267.         screenRect := screenBits.bounds;          {don't assume screen size}
  268.         {set drag rect to avoid menu bar, and keep at least 4 pixels on screen}
  269.         SetRect(dragRect, 4, 24, screenRect.right-4, screenRect.bottom-4);
  270.         {set up GrowRect, for limits on window growing}
  271.         SetRect(growRect, 48, 14, screenRect.right-7, screenRect.bottom-7);
  272.         {pull in and set up our menus}
  273.         SetUpMenus;
  274.      END; {SetUp}
  275.   {############################   DrawWindow   #################################}
  276.   {   We draw all the contents of our one window, myWindow.  Note that this must include
  277.    scroll bar areas and the grow icon; the Window Manager will NOT handle those for us.
  278.    Since there are no scroll bars, we must erase the region they would be in.  Echh.}
  279. PROCEDURE DrawWindow;
  280.    VAR aRect: rect; {rectangle to erase}
  281.    BEGIN {DrawWindow}
  282.       {first, fill the window with dark gray; this fills scroll bars, too}
  283.       FillRect(myWindow^.portRect, dkGray);
  284.       {second, erase the scroll bars and draw the grow icon}
  285.       {erase the horizontal scroll bar}
  286.       SetRect(aRect,          {cover the horizontal bar}
  287.               myWindow^.portRect.left,     myWindow^.portRect.bottom-15,
  288.               myWindow^.portRect.right-15, myWindow^.portRect.bottom);
  289.       FillRect(aRect, white);  {fill with white}
  290.       {erase the vertical scroll bar}
  291.       SetRect(aRect,          {cover the vertical bar}
  292.               myWindow^.portRect.right-15, myWindow^.portRect.top,
  293.               myWindow^.portRect.right,    myWindow^.portRect.bottom-15);
  294.       FillRect(aRect, white); {fill with white}
  295.       DrawGrowIcon(myWindow); {draw the size box in the corner of the window}
  296.     END; {DrawWindow}
  297.   {############################   UpdateWindow   #################################}
  298.   {   This is our response to receipt of an update event for myWindow.  Since the
  299.    window is likely to be inactive, the current grafPort will be elsewhere.  We must
  300.    change it for drawing, yet leave it as it was.}
  301.    PROCEDURE UpdateWindow(aWindow: WindowPtr);
  302.       VAR
  303.          savePort: GrafPtr;   {to save and restore the old port}
  304.       BEGIN {UpdateWindow}
  305.          BeginUpdate(aWindow); {reset ClipRgn etc to only redraw what's necessary.}
  306.          GetPort(savePort);    {don't trash the port; we might be updating an inactive window}
  307.          SetPort(aWindow);     {work in the specified window}
  308.          drawWindow;           {redraw contents of window}
  309.          SetPort(savePort);    {all nice and tidy as before}
  310.          EndUpdate(aWindow);
  311.       END; {UpdateWindow}
  312.   {############################   ReSize   #################################}
  313.   {   Called on a mouse-down in the grow box, this allows the user to change
  314.    the size of the window.  We change the size, then
  315.    claim that the whole of the window contents is no longer validly drawn,
  316.    because we're too lazy to do so for just the scroll bar regions
  317.    that are actually subject to change.  See the Window Manager.}
  318. PROCEDURE ReSize(a_window : WindowPtr; downPt: Point);
  319.    VAR w, h : integer;           {new width and height of the sized window}
  320.        newSize : longint;       {the new size}
  321.    BEGIN {ReSize}
  322.        newSize := GrowWindow(a_window, downPt, growRect); {find new size}
  323.        w := LoWord(newSize); {find the width}
  324.        h := HiWord(newSize); {find the height}
  325.        SizeWindow(a_window, w, h, true); {change to the new window size}
  326.        {place whole window into update region to be sure it all gets updated.
  327.         This is more than is strictly necessary, but a lot easier than just
  328.         invalidating the regions that actually may have changed.}
  329.        InvalRect(a_window^.portRect);
  330.     END; {ReSize}
  331.   {############################   MainEventLoop   #################################}
  332.   {   Brace yourself: here's where the action is.  Most Mac programs just wait for events
  333.    (as do we all), and then process them.  There are two sorts of events: those directly
  334.    initiated by the user, like key presses and mouse-downs, and those consequent events
  335.    posted by the Event Manager, like update and activate events.  The latter MUST be handled
  336.    correctly and carefully.  In particular, it's important for all events to make sure
  337.    that the event occurred in or for the window you expect -- it's possible to get events
  338.    which are not for one of our windows, despite GetNextEvent's return value.  Similarly,
  339.    be sure to check that the window it occured in is the active one, if it matters.
  340.       A common mistake in handling update and activate events is in finding out which window
  341.    they are for.  It is "WindowPtr(myEvent.message)" that gives this information,
  342.    NOT "whichWindow" (the WindowPtr returned by FindWindow).  The latter pointer merely tells
  343.    you what window the mouse was in at the time the event was posted -- completely irrelevant
  344.    for Update and Activate events.  Think it through carefully.}
  345.    PROCEDURE MainEventLoop;
  346.       VAR
  347.           myEvent: EventRecord;
  348.           whichWindow: WindowPtr;       {points to window of MouseDown}
  349.           windowCode: integer;          {what mouse was in when event posted}
  350.           userDone: boolean;            {true when user wants to exit program}
  351.   {############################   DoCommand   #################################}
  352.   {   We carry out the command indicated by mResult.
  353.    If it was Quit, we return true, else false.  Since the menu was highlighted by
  354.    MenuSelect, we must finish by unhighlighting it to indicate we're done.}
  355. FUNCTION DoCommand(mResult: LongInt): boolean;
  356.    CONST
  357.       AboutSkelId = 1;     {Resource ID of the string}
  358.       RattleID = 2;
  359.       FrightenID = 3;
  360.    VAR
  361.       refNum: integer;
  362.       theMenu, theItem: integer;
  363.       name: str255;
  364.       savePort: grafPtr;    {for saving current port in when opening a desk acc}
  365.       aStr: str255;
  366.       hStr: StringHandle;
  367.    BEGIN  {DoCommand}
  368.       DoCommand := false;            {assume Quit not selected}
  369.       theMenu := HiWord(mResult);    {get the menu selected}
  370.       theItem := LoWord(mResult);    {... and the item of that menu}
  371.       CASE theMenu OF
  372.          0: ;    {user made no selection; do nothing}
  373.          appleMenu:
  374.             begin
  375.             if theItem = 1
  376.               then begin;  {get string, and tell about Skel}
  377.                     {It's important not to pass Report a de-referenced handle;
  378.                      if Report were in another segment, loading it could
  379.                      caused a memory compaction; the de-referenced handle
  380.                      could become invalid.  Watch out for this and similar
  381.                      nasties everywhere in your program.
  382.                      See the Memory Manager and the Segment Loader.}
  383.                    hStr := GetString(AboutSkelId);
  384.            aStr := hStr^^;
  385.                    report(aStr);
  386.                    end
  387.               else begin   {run a desk accessory; make sure port is preserved}
  388.                    getPort(savePort);
  389.                    GetItem(myMenus[appleMenu], theItem, name);     {get name}
  390.                    refNum := OpenDeskAcc(name);          {run the desk accessory}
  391.                    setPort(savePort);
  392.                    end;
  393.             end;
  394.          fileMenu:
  395.             CASE theItem OF
  396.                iRattle: begin;                              {Rattle}
  397.                         hStr := GetString(RattleId);
  398.             aStr := hStr^^;
  399.                         report(aStr);
  400.                         end;
  401.                iFrighten: begin;                            {Frighten}
  402.                         hStr := GetString(FrightenId);
  403.             aStr := hStr^^;
  404.                         report(aStr);
  405.                         end;
  406.                iQuit:     DoCommand := true                 {Quit}
  407.             END; {fileMenu case}
  408.       END; {menu case }
  409.       HiliteMenu(0)        {turn off hilighting on the menu just used}
  410.    END; {DoCommand }
  411.    BEGIN  {MainEventLoop}
  412.       FlushEvents(EveryEvent, 0);    {discard leftover events}
  413.       {get next event, and handle it appropriately, until user QUITs}
  414.       userDone := false;
  415.       REPEAT
  416.          systemTask;       {handle desk accessories}
  417.          if GetNextEvent(everyEvent, myEvent)  {get event; if for us...}
  418.            then begin
  419.                 case myEvent.what of           {handle each kind of event}
  420.                    mouseDown:
  421.                       begin
  422.                          {find out what window the mouse went down in, and where in it}
  423.                          windowCode := FindWindow(myEvent.where, whichWindow);
  424.                          case windowCode of     {handle mouse-down for each place}
  425.                             inSysWindow:          {handle the desk accessories}
  426.                                   SystemClick(myEvent, whichWindow);
  427.                             inMenuBar:  {handle the command}
  428.                                   userDone := DoCommand(MenuSelect(myEvent.where));
  429.                             inDrag:     {drag the window}
  430.                                   DragWindow(whichWindow, myEvent.where, dragRect);
  431.                             inContent:   {includes inGrow if window inactive. Activate window}
  432.                                   if whichWindow = myWindow  {moke sure it's for mine}
  433.                                     then if whichWindow <> FrontWindow
  434.                                            then SelectWindow(whichWindow);   {make it active}
  435.                             inGrow:  {window is already active; change its size}
  436.                                   if whichWindow = myWindow  {moke sure it's for mine}
  437.                                     then ReSize(myWindow, myEvent.where);
  438.                             inGoAway:   {we don't have a GoAway region}
  439.                          end; {case windowCode}
  440.                       end;  {mouseDown handling}
  441.                    keyDown, autoKey:   {if command key, pass the char to MenuKey}
  442.                       if BitAnd(myEvent.modifiers, cmdKey) <> 0
  443.                         then userDone := DoCommand(MenuKey(chr(BitAnd(myEvent.message, charCodeMask))));
  444.                    updateEvt: {if it's for our window, update it}
  445.                       if WindowPtr(myEvent.message) = myWindow
  446.                         then UpdateWindow(myWindow);             {redraw the window contents}
  447.                    activateEvt:      {if for our window, set port as nec.}
  448.                       if WindowPtr(myEvent.message) = myWindow       {my window}
  449.                         then begin
  450.                              DrawGrowIcon(myWindow);     {redraw grow icon to reflect new state}
  451.                              if odd(myEvent.modifiers)   {odd means an activate event}
  452.                                then SetPort(myWindow)    {activate evt: work in our own port}
  453.                                else SetPort(screenPort); {deactivate evt: our port is gone;
  454.                                                           keep port from dangling}
  455.                              end;
  456.                 end;  {case myEvent.what}
  457.                 end;  {THEN BEGIN for "it's our event"}
  458.       UNTIL userDone;
  459.    END; {MainEventLoop}
  460.    BEGIN {Skel}
  461.       SetUp;
  462.       MainEventLoop;
  463.    END. {Skel}
  464.